#include "SongName.h"
#include "Input/InputManager.h"
#include "Assets/FontManager.h"
#include "Graphics/GraphicsManager.h"

SongName::SongName(const tstring& songName)
	: Object(),
	m_PosX(0.0f),
	m_Speed(30.0f),
	m_SongName(songName),
	m_pText(nullptr)
{

}

SongName::~SongName()
{
}

void SongName::Initialize()
{
	star::FontManager::GetInstance()->LoadFont(_T("PixelMotion.ttf"),_T("PixelMotion"), 40);
	
	m_pText = new star::TextComponent(_T("PixelMotion.ttf"),_T("SongName"), 40, false);
	m_pText->SetText(m_SongName);
	AddComponent(m_pText);
}

void SongName::Update(const star::Context& context)
{
	m_PosX -= m_Speed * static_cast<float>(context.mTimeManager->GetSeconds());
	float temp = static_cast<float>(m_SongName.length()) * -3.0f;
	
	if(m_PosX < temp)
	{
		m_PosX = static_cast<float>(star::GraphicsManager::GetInstance()->GetTargetWindowWidth()) + 5.0f; 
	}
	GetTransform()->Translate(m_PosX, 9.0f);
}